<?php
/**
 * Created by PhpStorm.
 * User: Lenovo
 * Date: 2018/11/29
 * Time: 14:34
 */

namespace app\index\controller;


use app\index\model\Submessage;

class Submessages extends Comm
{
    public function Opinion(){
        $re=Submessage::where('type',0)->order('status asc')->order('create_time')->select();
        $res=Submessage::where('type',0)->where('status',0)->count();
        return view('opinion',['opinion'=>$re,'status'=>$res,'i'=>1]);
    }
    public function Contribute(){
        $re=Submessage::where('type',1)->order('status asc')->order('create_time')->select();
        $res=Submessage::where('type',1)->where('status',0)->count();
        return view('contribute',['contribute'=>$re,'status'=>$res,'i'=>1]);
    }
    public function Order(){
        $re=Submessage::where('type',2)->order('status asc')->order('create_time')->select();
        $res=Submessage::where('type',2)->where('status',0)->count();
        return view('order',['order'=>$re,'status'=>$res,'i'=>1]);
    }
    public function updstatus(){
        $re=Submessage::find($_POST['id']);
        $re->status=1;
        $re->save();
    }
    public function updallstatus(){
        $re=Submessage::updallstatus($_POST['type']);
        if($re){
            show('1','处理成功');
        }else{
            show('0','处理失败');
        }
    }
    public function del(){
        $id=$_POST['id'];
        $re=Submessage::destroy($id);
        if($re==false){
            show(0,'删除失败');
        }else{
            show(1,'删除成功');
        }
    }
}